package pers.weiney.mapper;


import org.apache.ibatis.annotations.*;
import pers.weiney.pojo.Category;

import java.util.List;

/**
 * @Author: @Weiney
 * @ClassName: CategoryMapper
 * @Description: 文章分类数据库接口
 * @Create: 2024-08-13
 **/
@Mapper
public interface CategoryMapper {
    /**
     * @param category
     * @return void
     * @author @Weiney
     * @description 添加分类
     **/
    @Insert("insert into category(category_name, category_alias, create_user, create_time, update_time)" +
            "values (#{categoryName}, #{categoryAlias}, #{createUser}, #{createTime}, #{updateTime});")
    void insertCategory(Category category);

    /**
     * @param createUser
     * @return List<Category>
     * @author @Weiney
     * @description 获取分类列表
     **/
    @Select("select * from category where create_user=#{createUser}")
    List<Category> selectAll(Integer createUser);

    /**
     * @param id
     * @return Category
     * @author @Weiney
     * @description 根据分类id查询分类信息
     **/
    @Select("select * from category where id=#{id}")
    Category selectById(Integer id);

    /**
     * @param category
     * @return void
     * @author @Weiney
     * @description 更新分类信息
     **/
    @Update("update category " +
            "set category_name=#{categoryName}, category_alias=#{categoryAlias}, update_time=#{updateTime} " +
            "where id=#{id}")
    void update(Category category);

    /**
     * @param id
     * @return void
     * @author @Weiney
     * @description 根据分类id删除分类
     **/
    @Delete("delete from category where id=#{id}")
    void delete(Integer id);
}
